<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>开始订单</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="tabbtnarea">
    <li class="w50 rline"><span class="tabfouse">订单信息</span></li>
    <li class="w50" id="fee_detail">费用明细</li>
</section>
<section class="itemgroup mt44">
    <div class="order_title" id="waybillNum">
        订单编号: <label class="type ml5">APP</label>
        <label class="right green">进行中</label>
    </div>
    <div class="twoitem ml15">
        <div class="w50 left">
            <label class="itemsubname">下单时间</label>
            <label class="font14" id="orderDate"></label>
        </div>
        <div class="w50 right">
            <label class="itemsubname">预订时间</label>
            <label class="font14" id="bookDates"></label>
        </div>
    </div>
    <div class="photoitem ml15 font14" id="startAddr">
        <i class="iconfont mr5 green icon20">&#xe70d;</i>
    </div>
    <div class="photoitem ml15 font14" id="endAddr">
        <i class="iconfont mr5 red icon20">&#xe70c;</i>
    </div>
    <div id="requireList">
    <div class="oneitem p15">
        <label class="gray font12">特殊要求:</label>
        <div class="comments_type right">备注</div>
    </div>
    </div>
</section>
<section class="subtitle p15 mt10">叫车人信息</section>
<section class="itemgroup">
    <div class="normalitem">
        <div class="userphoto"><img src="../../img/user_photo.png" width="100%" height="100%"/></div>
        <div class="photoitem lh20">
            <div class="itemname">
                <span id="consignName"></span>
                <i class="iconfont rightsmallicon">&#xe6db;</i>
                <span class="right gray font12" onclick="call();">联系TA</span>
            </div>
            <div class="itemsubname" id="consignMobile"></div>
        </div>
    </div>
</section>
<section class="itemgroup mt10 mb56">
    <div class="order_title">
        给司机捎句话
    </div>
    <div class="pall15 font14 lh24" id="consignDesc"></div>
</section>
<section class="bottomarea">
    <button type="button" class="btn bottomonebtn" id="goonBid1">开始订单</button>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    var waybillId = "";
    var globalStatus = 10;
    $(document).ready(function () {
        waybillId = GetArgsFromHref("waybillId");
        var url = _global.serverHost + "/driver/start_bid.htm";
        var data = {waybillId: waybillId};
        _callAjaxRequest(url, data, startBidBack);

        function startBidBack(data) {
            var waybillSource = "";
            if (data.waybill.waybillSource == '10') {
                waybillSource = "<label class='type ml5'>APP</label>";
            } else if (data.waybill.waybillSource == '20') {
                waybillSource = "<label class='type ml5'>网站</label>";
            } else if (data.waybill.waybillSource == '30') {
                waybillSource = "<label class='type ml5'>客服电话</label>";
            } else if (data.waybill.waybillSource == '40') {
                waybillSource = "<label class='type ml5'>微信</label>";
            }
            
            var order_status = "未开始";
            if (data.waybill.status =='00') {
                order_status = "已取消";
            } else if (data.waybill.status < 35) {
                order_status = "未开始";
            } else if (data.waybill.status >= 35 && data.waybill.status < 70) {
                order_status = "进行中";
            } else if (data.waybill.status >= 70 && data.waybill.status < 80) {
                order_status = "待付款";
            } else if (data.waybill.status >= 80 && data.waybill.status < 90) {
                order_status = "待评价";
            }	else if (data.waybill.status = 90) {
                order_status = "已完成";
                globalStatus = 90;
            }
            
            $("#waybillNum").html('订单编号: ' + data.waybill.waybillNum + waybillSource
                    + '<label class="right green">'+order_status+'</label>');

            $("#orderDate").html(data.waybill.orderDate);
            $("#bookDates").html(data.waybill.bookDates);
            $("#startAddr").html('<i class="iconfont mr5 green icon20">&#xe70d;</i>' + (data.waybill.startDistrict+data.waybill.startStreet));
            $("#endAddr").html('<i class="iconfont mr5 red icon20">&#xe70c;</i>' + (data.waybill.endDistrict+data.waybill.endStreet));

            var require = "";
            if (data.requireList > 0) {
                require = '<div class="oneitem p15">'
                        + '<label class="gray font12">特殊要求:</label>';
                for (var j = 0; j < data.requireList.length; j++) {
                    require = require + '<div class="comments_type right';
                    if (j > 0) {
                        require = require + ' mr5';
                    }
                    require = require + '">' + data.requireList[j].requirementName + '</div>';
                }
                require = require + '</div>';
            }
            $("#requireList").html(require);
            $("#consignName").html(data.waybill.consignName);
            if(data.waybill.status != 90){
            	$("#consignMobile").html(data.waybill.consignMobile);
          	}
            tel = data.waybill.consignMobile;
            $("#consignDesc").html(data.waybill.consignDesc);

            $("#fee_detail").attr("onclick", "goStartBidFee('" + data.waybill.waybillId + "')");
            $("#goonBid1").attr("onclick", "goonBid1('" + data.waybill.waybillId + "')");
            
            if(data.waybill.status==90 || data.waybill.status==80 || data.waybill.status==70){
            		$("#goonBid1").hide();
            }
        }
    });
    function goonBid1(waybillId){
        var url = _global.serverHost + "/driver/check_start_bid.htm";
        var data = {waybillId: waybillId,driverUuid: getCookie("driverUuid")};
        _callAjaxRequest(url, data, goonBid1Back);
    }
    function goonBid1Back(data){
        if (data.code == "1") {
        		//setCookie("waybillId", data.waybillId);
        		try{
		        	delegate.setCookie("billidcookie", data.waybillId+"");
		      	}catch(e){
		      		alert(e);	
		      	}
            window.location.href="../start_bid/goon_bid1.html?waybillId="+data.waybillId;
        } else {
            alert(data.message);
        }
    }

    function goStartBidFee(waybillId){
        window.location.href="../start_bid/start_bid_fee.html?waybillId="+waybillId;
    }
    
    var tel = "";
    function call() {
    		if(globalStatus!=90){
        	delegate.call(tel);
      	}
    }
</script>
</body>
</html>